package dao.oc_station_ben;

import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import entitybean.oc_station_ben.EntityBeanOc_Station_Ben;

public class DaoImpl_Oc_Station_Ben  extends HibernateDaoSupport implements Dao_Oc_Station_Ben{
	public void Insert_Oc_Station_Ben(EntityBeanOc_Station_Ben e)
	{
		this.getHibernateTemplate().save(e);
	}
	public void Update_Oc_Station_Ben(EntityBeanOc_Station_Ben e)
	{
		this.getHibernateTemplate().update(e);
	}
	public void Delete_Oc_Station_Ben(EntityBeanOc_Station_Ben e)
	{
		this.getHibernateTemplate().delete(e);
	}
	@SuppressWarnings("unchecked")
	public void Delete_Oc_Station_Ben(String id)
	{
		List<EntityBeanOc_Station_Ben> list=this.getHibernateTemplate().find("from EntityBeanOc_Station_Ben where del='OFF' and id in("+id+")");	
		for(int i=0;i<list.size();i++)
		{
			EntityBeanOc_Station_Ben e=list.get(i);
			e.setDel("ON");
			this.getHibernateTemplate().update(e);
			
		}
		
	}
	@SuppressWarnings("unchecked")
	

	
	public List<EntityBeanOc_Station_Ben> Find_Oc_Station_Ben_by_oc_voyage_id(Integer id)
	{
		return this.getHibernateTemplate().find("from EntityBeanOc_Station_Ben where del='OFF' and oc_voyage_id="+id);
	}
	@SuppressWarnings("unchecked")
	public List<EntityBeanOc_Station_Ben> Find_Oc_Station_Ben_by_oc_voyage_id(Integer id,Integer j)
	{
		return this.getHibernateTemplate().find("from EntityBeanOc_Station_Ben where  territorial_waters="+j+" and del='OFF' and oc_voyage_id="+id);
	}
	@SuppressWarnings("unchecked")
	public EntityBeanOc_Station_Ben Find_Oc_Station_Ben_by_oc_id(Integer id)
	{
		EntityBeanOc_Station_Ben e= new EntityBeanOc_Station_Ben();
		List<EntityBeanOc_Station_Ben> list=this.getHibernateTemplate().find("from EntityBeanOc_Station_Ben where del='OFF' and id="+id);
		if(list.size()>0)
		{
			e=list.get(0);
		}
		return e;
	}
	@SuppressWarnings("unchecked")
	public EntityBeanOc_Station_Ben Find_Oc_Station_Ben_by_L_D(String L,String D,String voyage)
	{
		EntityBeanOc_Station_Ben e= new EntityBeanOc_Station_Ben();
		List<EntityBeanOc_Station_Ben> list=this.getHibernateTemplate().find("from EntityBeanOc_Station_Ben where del='OFF' " +
				"and oc_voyage_id="+voyage+" and longitude='"+L+"' AND dimensionality='"+D+"'");
		if(list.size()>0)
		{
			e=list.get(0);
		}
		return e;
		
	}
	@SuppressWarnings("unchecked")
	public List<EntityBeanOc_Station_Ben> Find_Oc_Station_Ben_is_active()
	{
		
		return this.getHibernateTemplate().find("from EntityBeanOc_Station_Ben where del='OFF'");
	}
}
